from src.application.proxy.dto.proxy import ProxyDTO
from src.domain.order.entities.proxy import ProxyEntity
from src.infrastructure.db import models


def convert_proxy_entity_to_db_model(proxy: ProxyEntity) -> models.Proxy:
    return models.Proxy(
        id=proxy.id,
        login=proxy.login,
        password=proxy.password,
        port_https=proxy.port_https,
        reload_link=proxy.reload_link,
        server_id=proxy.server_id,
        authorization_type=proxy.authorization_type,
        status=proxy.status,
        reload_type=proxy.reload_type,
        reload_period=proxy.reload_period,
    )


def convert_db_model_to_proxy_dto(proxy: models.Proxy) -> ProxyDTO:
    return ProxyDTO(
        id=proxy.id,
        login=proxy.login,
        password=proxy.password,
        server_id=proxy.server_id,
        reload_link=proxy.reload_link,
        port_https=proxy.port_https,
        status=proxy.status,
    )


def convert_db_model_to_proxy_entity(proxy: models.Proxy) -> ProxyEntity:
    return ProxyEntity(
        id=proxy.id,
        login=proxy.login,
        password=proxy.password,
        server_id=proxy.server_id,
        reload_link=proxy.reload_link,
        port_https=proxy.port_https,
        status=proxy.status,
    )
